<template>
	<view class="mainpadding">
		<view class="flexleft" @click="messageTime.timeShow = true">
			{{searchtime}}
			<view style="margin-left: 20rpx;">
				<u-icon name="arrow-down"></u-icon>
			</view>
		</view>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;"></view>
		</view>
		<view class="xiahuaxian  margin_top" v-for="item in list.data" :key="item.id">
			<view class="flexleft">
				<image :src="item.user.avatar_text" class="headimg margin_right2" mode=""></image>
				<view class="ershiba xiaohei strongtext">{{item.user.nickname}}</view>
			</view>
			<view class="flexbetween margin_top2">
				<view class="">
					<view class=" ershil xiaohei nofonweight ">{{item.memo}}</view>
					<view class="margin_top1 strongtext xiaohui nofonweight ">{{item.createtime_text}}</view>
				</view>
				<view class=" sanshier xiaohei fonweight ">{{item.money}}</view>
			</view>
		</view>
		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				messageTime: {
					timeShow: false,
					title: "选择筛选年月",
					mode: "year-month" //date日期，datetime年月日时分秒，time时间,year-month年月
				},
				searchtime: "",
				user_zbfapply_listid:""
			}
		},
		onLoad(options) {
			this.searchtime = this.benyue()
			this.user_zbfapply_listid = options.user_zbfapply_listid
			this.init()
		},
		methods: {
			benyue() {
				let y = new Date().getFullYear(); //获取年份
				let m = new Date().getMonth() + 1; //获取月份
				let d = '01'
				m = m < 10 ? '0' + m : m; //月份补 0
				return [y, m].join("-")
			},
			init(isPage, page) {
				let _this = this;
				let url = "/api/user/hycardMoneyLog"
				httpRequest.request(url, 'GET', {
					page: page || 1,
					limit: _this.limit,
					searchtime: this.searchtime,
					user_zbfapply_id: this.user_zbfapply_listid
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			timeConfirm(e) {
				this.searchtime = e
				this.init()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.headimg {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}
</style>